﻿using System.Collections.Generic;
using System.Linq;
using PersonaLibrary.Data;

namespace PersonaLibrary.ViewModel.EmployeeViewModel
{
    public class FullEmployeeViewModel : LinqEditableItem<Employee, View.EmploeeView.EmploeeDetail>
    {
        public FullEmployeeViewModel()
        {
            EditableItem = new Employee();
            SexSource = Context.Sexes.ToList();
        }

        public FullEmployeeViewModel(int id)
        {
            EditableItem = Context.Employees.Single(x => ((Employee)x).Id == id);
            EditableItem.LoadConnections();
            EditableItem.LoadNotes();
            SexSource = Context.Sexes.ToList();
         }

        #region Pupblic Properties

        public List<Sex> SexSource { private set; get; }
        
        #endregion
        
        #region Parent override

        public override void Dispose()
        {
        }

        public override bool CanCommit()
        {
            if (string.IsNullOrEmpty(EditableItem.Surname)) 
				return false;            
            return true;
        }

        #endregion
    }
}
